package p3;

import java.util.Random;
import java.util.Scanner;

/**
 * @author krystal
 * @date 2022/11/9 19:46
 */
public class Demo10 {
    public static void main(String[] args) {
        Random random=new Random();
        Scanner scanner=new Scanner(System.in);
        int toGuess=random.nextInt(100);
        while (true){
            System.out.println("请输入您猜的数字：");
            int num=scanner.nextInt();
            if (num < toGuess){
                System.out.println("小了");
            }else if (num > toGuess){
                System.out.println("大了");
            }else {
                System.out.println("猜对了");
                break;
            }
        }
        scanner.close();
    }
}
